package fr.enseirbmatmeca.apms.spring.service.impl;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import fr.enseirbmatmeca.apms.hibernate.dao.ProjectDAO;
import fr.enseirbmatmeca.apms.spring.model.project.Project;
import fr.enseirbmatmeca.apms.spring.model.project.ProjectCollection;
import fr.enseirbmatmeca.apms.spring.model.project.ProjectGroup;
import fr.enseirbmatmeca.apms.spring.model.user.User;
import fr.enseirbmatmeca.apms.spring.service.ProjectManager;

/**
 * Implements features to handler projects
 *
 * @author coudar
 */
@Service("projectManager")
@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
public class ProjectManagerImpl implements ProjectManager {

    private final Log logger = LogFactory.getLog(ProjectManagerImpl.class);
    @Autowired
    private ProjectDAO projectDAO = null;

    @Transactional(readOnly = false)
    public String assignProject(User user, Project project, int role) {
        // TODO Auto-generated method stub
        return null;
    }
    
    @Transactional(readOnly = false)
	public String CreateProjectGroup(ProjectGroup pg) {
		projectDAO.createProjectGroup(pg);
		return "created";
	}

    /**
     * {@inheritDoc}
     */
    @Transactional(readOnly = false)
    public String createProject(Project project) {
    	projectDAO.createProject(project);
        return "created";
    }

    @Transactional(readOnly = false)
    public String CreateProjectCollection(ProjectCollection cp) {
    	projectDAO.createProjectCollection(cp);
        return "created";
    }

    @Transactional(readOnly = false)
    public String createTag(String tag) {
        // TODO Auto-generated method stub
        return null;
    }

    @Transactional(readOnly = false)
    public String deleteProject(Project project) {
        // TODO Auto-generated method stub
        return null;
    }

    @Transactional(readOnly = false)
    public String deleteProjectCollection(ProjectCollection project) {
        // TODO Auto-generated method stub
        return null;
    }

    @Transactional(readOnly = false)
    public String deleteTag(String tag) {
        // TODO Auto-generated method stub
        return null;
    }

    public ProjectCollection getProjectCollection() {
        // TODO Auto-generated method stub
        return null;
    }

    public ProjectCollection getProjectCollection(User user) {
        // TODO Auto-generated method stub
        return null;
    }

    /**
     * {@inheritDoc}
     */
    public List<Project> getProjects() {
        // TODO Auto-generated method stub
        return null;
    }

    /**
     * {@inheritDoc}
     */
    public List<Project> getProjects(User user) {
        return projectDAO.getProjects(user);
    }

    public boolean sendEmailWarningUnuploadedReports() {
        // TODO Auto-generated method stub
        return false;
    }

    /**
     * setter to allows spring to inject projectDAO implementation
     *
     * @param projectDAO : object (implementation of projectDAO interface) to
     * inject.
     */
    public void setProjectDAO(ProjectDAO projectDAO) {
        this.projectDAO = projectDAO;
    }

    @Transactional(readOnly = false)
    public String setProjectStatusByTag(int projectStatus, String tag) {
        // TODO Auto-generated method stub
        return null;
    }

    @Transactional(readOnly = false)
    public String updateProject(Project project) {
        // TODO Auto-generated method stub
        return null;
    }

	public boolean checkProjectIntoProjectCollection(String projectId,
			String projectCollectionId) {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean checkProjectIntoProjectGroup(String projectId,
			String projectGroupId) {
		// TODO Auto-generated method stub
		return false;
	}

}